/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: Dec 31, 2009
 * Time: 10:33:18 AM
 * To change this template use File | Settings | File Templates.
 */

import java.util.HashSet;
import java.util.Set;
import org.jdom.Element;

// Referenced classes of package dk.brics.dsd:
//            Validator

class Context
{

    Context(Element element, Validator validator)
    {
        e = element;
        v = validator;
    }

    Context(Element element, Element element1, Validator validator)
    {
        e = element;
        this_e = element1;
        v = validator;
    }

    Context(Graph graph, Node node, Element element, Validator validator)
    {
        sg = graph;
        e = element;
        n = node;
        v = validator;
    }

    Context(Graph graph, Node node, Element element, Node node1, Element element1, Validator validator)
    {
        sg = graph;
        e = element;
        n = node;
        this_e = element1;
        this_n = node1;
        v = validator;
    }

    void enterDef(String s)
    {
        if(indefs == null)
            indefs = new HashSet();
        indefs.add(s);
    }

    void leaveDef(String s)
    {
        indefs.remove(s);
        if(indefs.size() == 0)
            indefs = null;
    }

    boolean containsDef(String s)
    {
        if(indefs == null)
            return false;
        else
            return indefs.contains(s);
    }

    public boolean equals(Object obj)
    {
        if(!(obj instanceof Context))
        {
            return false;
        } else
        {
            Context context = (Context)obj;
            return e == context.e && n == context.n && sg == context.sg && this_e == context.this_e && this_n == context.this_n;
        }
    }

    public int hashCode()
    {
        return 2 * (e == null ? 0 : e.hashCode()) + 3 * (n == null ? 0 : n.hashCode()) + 5 * (this_e == null ? 0 : this_e.hashCode()) + 7 * (this_n == null ? 0 : this_n.hashCode());
    }

    Graph sg;
    Element e;
    Node n;
    Element this_e;
    Node this_n;
    Validator v;
    Set indefs;
}

